﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Facade;
using Common;

namespace FriendsNow
{
    public partial class SignUp : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            IDValidateLabel.Visible = false;
        }

        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            String id = IDTextBox.Text;
            String name = NameTextBox.Text;
            String sex = SexDropDownList.SelectedValue;
            String code = CodeTextBox.Text;
            String email = EmailTextBox.Text;
            String securityquestion = SecurityQuestionTextBox.Text;
            String securityanswer = SecurityAnswerTextBox.Text;

            User newuser = new User(id, name, sex, code, email, securityanswer, securityanswer);
            UserManger.UserManager newusermanager = new UserManger.UserManager();

            if (newusermanager.CreateUser(newuser) == 0)
            {
                IDValidateLabel.Visible = true;
            }
            else
            {

                Response.Redirect(@"~/Default.aspx");
            }

        }

        protected void LogOutButton_Click(object sender, EventArgs e)
        {
            Response.Redirect(@"~/Default.aspx");
        }
    }
}
